#!/bin/sh
#/etc/init.d/snmpcollector

APPDIR=/opt/snmpcollector
PID=/var/run/snmpcollector.pid

case "$1" in
   start)
     echo "Starting snmpcollector"
	   export PWD=$APPDIR
     start-stop-daemon --start --quiet --make-pidfile --pidfile $PID --chdir $APPDIR --background --exec ./snmpcollector -- -config $APPDIR/conf/config.toml -logs $APPDIR/log
     ;;
   stop)
     echo "Stopping snmpcollector"
     start-stop-daemon --stop --pidfile $PID
	 rm -f $PID
     ;;
   *)
     echo "Usage: /etc/init.d/snmpcollector{start|stop}"
     exit 1
     ;;
esac

exit 0
